package com.dailyyoga.res;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;

class ApkInstall extends InstallImp {

	public ApkInstall(Context context, String plugid) {
		super(context, plugid);
	}

	public void install(String zipfile, String plugsId) {
		String downloadURL = "https://market.android.com/details?id=";

		Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(downloadURL
				+ plugsId));
		try {
			mContext.createPackageContext("com.android.vending",
					Context.CONTEXT_IGNORE_SECURITY
							| Context.CONTEXT_INCLUDE_CODE);
			intent.setPackage("com.android.vending");
			mContext.startActivity(intent);
		} catch (NameNotFoundException e) {
			mContext.startActivity(intent);
		}
	}

	public void unInstall(String plugsId) {

		Uri packageURI = Uri.parse("package:" + plugsId);
		Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
		uninstallIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		mContext.startActivity(uninstallIntent);

	}

}
